<?PHP
if (!session_start()) { session_start(); };
/*if (!isset($_SESSION['lgnapproved'])) {
	die(header('Location: login.php'));
}*/

include("functions.php");
include("cnnxn.php");
connect();

if (isset($_POST['submit'])) {

	$fieldnames="";
	$fieldvalues="";
	while (list($key,$value) = each($_POST)) {
		$fieldnames=$fieldnames.$key.',';
		if (ctype_digit($value)) {
		   $fieldvalues=$fieldvalues.$value.',';
	   } else {
		   $fieldvalues=$fieldvalues.'"'.addslashes($value).'",';
	   }
	}
	$fieldnames=substr_replace($fieldnames,"",-8);
	$fieldvalues=substr_replace($fieldvalues,"",-10);
	$SQLadd='INSERT INTO av_players ('.$fieldnames.') VALUES ('.$fieldvalues.');';
	//print $SQLadd;
	$sendit_add=mysqli_query($db,$SQLadd) or die(mysqli_error($db));
	mysqli_close($db);
	
	if (isset($_GET['did'])) {
		die(header("Location: av_players_viewall.php?did=".$_GET['did']));
	} else {
		die(header("Location: av_players_viewall.php"));
	}
}
?>